﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace IISLogAnalyzer
{
    public static class GetServiceInfo
    {
        private static string fileName = System.IO.Directory.GetCurrentDirectory() + "\\Service.xml";
        public static List<string> GetServiceInfoLst()
        {
            if (File.Exists(fileName))
            {
                using (FileStream reader = new FileStream(fileName, FileMode.Open))
                {
                    List<string> lstServiceInfo = new List<string>();
                    ServiceInfo tmpServiceInfo = new ServiceInfo();
                    XmlSerializer readxmlTP = new XmlSerializer(typeof(ServiceInfo));
                    tmpServiceInfo = ((ServiceInfo)readxmlTP.Deserialize(reader));
                    foreach (string str in tmpServiceInfo.ServiceName)
                    {
                        lstServiceInfo.Add(str);
                    }
                    return lstServiceInfo;
                }
            }
            return null;
        }
    }
}
